#region

using System;
using VeeTileEngine2012;

#endregion

namespace TimeDRODPOF.TDComponents
{
    public class TDCSwitchRecalculateTagAI : Component
    {
        public TDCSwitchRecalculateTagAI(TDCSwitch mSwitchComponent, TDCRecalculateSprites mRecalculateComponent, string mOffTag, string mOnTag)
        {
            SwitchComponent = mSwitchComponent;
            RecalculateComponent = mRecalculateComponent;
            OffTag = mOffTag;
            OnTag = mOnTag;
        }

        public TDCSwitch SwitchComponent { get; set; }
        public TDCRecalculateSprites RecalculateComponent { get; set; }
        public string OffTag { get; set; }
        public string OnTag { get; set; }

        public override void Added()
        {
            base.Added();

            RecalculateComponent.Tag = SwitchComponent.IsOff ? OffTag : OnTag;

            SwitchComponent.OnTurnOn += () => { RecalculateComponent.Tag = OnTag; };
            SwitchComponent.OnTurnOff += () => { RecalculateComponent.Tag = OffTag; };
        }
    }
}